package org.iks.common.exception;

import lombok.Getter;
import org.iks.common.ResultCode;

/**
 * @author kzou
 * @date 2023/11/18 11:18
 * @description: 业务异常
 */
@Getter
public class BusinessException extends RuntimeException {
    private final String errorMessage;

    private final int errorCode;

    public BusinessException(int code, String errorMessage) {
        this(errorMessage, code);
    }

    public BusinessException(String errorMessage, int code) {
        super(errorMessage);
        this.errorCode = code;
        this.errorMessage = errorMessage;
    }

    public BusinessException(ResultCode result) {
        this(result.getMessage(), result.getCode());
    }

    public BusinessException(String msg) {
        this(msg, ResultCode.ERROR.getCode());
    }

}
